package io.geekidea.boot.test.controller;

import io.geekidea.boot.framework.page.Paging;
import io.geekidea.boot.framework.response.ApiResult;
import io.geekidea.boot.test.query.AppPayRecordQuery;
import io.geekidea.boot.test.service.PayRecordService;
import io.geekidea.boot.test.vo.AppPayRecordVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * App消费记录 控制器
 *
 * @author geekidea
 * @since 2025-03-26
 */
@Slf4j
@RestController
@Tag(name = "App消费记录")
@RequestMapping("/app/payRecord")
public class AppPayRecordController {

    @Autowired
    private PayRecordService payRecordService;

    /**
     * 获取App消费记录详情
     *
     * @param id
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App消费记录详情")
    @PostMapping("/getAppPayRecord/{id}")
    public ApiResult<AppPayRecordVo> getAppPayRecord(@PathVariable Long id) {
        log.info("获取App消费记录详情：{}", id);
        AppPayRecordVo appPayRecordVo = payRecordService.getAppPayRecordById(id);
        return ApiResult.success(appPayRecordVo);
    }

    /**
     * 获取App消费记录分页列表
     *
     * query
     * @return
     * @throws Exception
     */
    @Operation(summary = "获取App消费记录分页列表")
    @PostMapping("/getAppPayRecordPage")
    public ApiResult<AppPayRecordVo> getAppPayRecordPage(@Valid @RequestBody AppPayRecordQuery query) {
        log.info("获取App消费记录分页列表：{}", query);
        Paging<AppPayRecordVo> paging = payRecordService.getAppPayRecordPage(query);
        return ApiResult.success(paging);
    }

}
